package com.yulinlin.admin.modules.generate.domain.config;

import com.yulinlin.common.domain.enums.EnumItem;
import com.yulinlin.common.domain.enums.EnumUtil;
import com.yulinlin.common.domain.enums.SuperEnum;
import com.yulinlin.admin.modules.generate.domain.TableInfo;
import lombok.Data;

import java.util.List;

@Data
public class TableViewConfig {

    private List<TableInfo> list;

    private List<EnumItem> groupTypeList;

    private List<EnumItem> dataTypeList;

    public static TableViewConfig newInstance(){
        TableViewConfig config = new TableViewConfig();
        config.groupTypeList  = EnumUtil.getEnumList(GroupType.values());
        config.dataTypeList  = EnumUtil.getEnumList(DataType.values());
        return config;

    }


    public static enum GroupType implements SuperEnum<String> {

        string("字符串"),
        day("天"),
        month("月"),
        year("年"),

        ;

        private String label;

        GroupType(String label) {
            this.label = label;
        }

        @Override
        public String getLabel() {
            return label;
        }

        @Override
        public String getValue() {
            return name();
        }
    }


    public static enum DataType implements SuperEnum<String> {
        count("总数"),
        sum("和"),
        avg("平均"),
        ;

        private String label;

        DataType(String label) {
            this.label = label;
        }

        @Override
        public String getLabel() {
            return label;
        }

        @Override
        public String getValue() {
            return name();
        }
    }

}
